package de.koller.pulsar.scene.planet;

import de.koller.aframe.util.math.IFunction;
import de.koller.oceanFramework.math.IProjection;
import de.koller.oceanFramework.math.RVec3;

public class StarBrightness implements IFunction {

	private final IProjection projection;
	private final double brightness;
	private final double radius;
	
	public StarBrightness( double brightness, double radius, IProjection projection ) {
		this.brightness = brightness;
		this.radius = radius;
		this.projection = projection;
	}
	
	@Override
	public float getValue( float x ) {
		double d = projection.project( new RVec3( (float)radius, 0, x ), null ).x 
				 - projection.project( new RVec3( 0, 0, x ), null ).x;
		
		return (float)( Math.PI * d * d * brightness );
	}
	
}
